package com.etbsms.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import com.etbsms.dao.ILogLoginDAO;
import com.etbsms.domain.LogLogin;
import com.etbsms.domain.Users;

@Repository
@Component("logloginDAO")
public class LogLoginDAOImpl extends GenericDAOImpl<LogLogin, Integer> implements ILogLoginDAO{

	@Override	
	@SuppressWarnings("unchecked")
	public List<LogLogin> getUsersLoginLog(Users users) {
		Session session = sessionFactory.openSession();
		Criteria criteria = session.createCriteria(LogLogin.class);	
		criteria.add(Restrictions.eq("users", users));
		criteria.addOrder(Order.desc("login_time"));	
		List<LogLogin> list = criteria.list();
		session.close();		
		return list;
	}

}
